﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using ExampleDLL.Entities;


namespace ExampleDLL
{
   public class XMLHandler
    {
        public static bool WriteXML(Missile mis)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(docNode);
                XmlNode missileNode = doc.CreateElement("missile");
                doc.AppendChild(missileNode);
                XmlNode speedNode = doc.CreateElement("speed");
                speedNode.AppendChild(doc.CreateTextNode(mis.Speed.ToString()));
                missileNode.AppendChild(speedNode);
                doc.Save("missile.xml");
                return true;
            }
            catch (Exception ex)
            {
                //Write to log file
                return false;
            }
            
        }



    }
}
